package com.code.exam.mapper;

import com.code.exam.dto.QuestionDTO;
import com.code.exam.dto.QuestionPageQueryDTO;
import com.code.exam.entity.Question;
import com.code.exam.vo.QPageResultVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface QuestionMapper {

    @Insert("insert into question(id,content,options,answer,type,created_by) " +
            "values (#{id},#{content},#{options},#{answer},#{type},#{createdBy})")
    void addQuestion(Question question);


    @Update("UPDATE question " +
            "SET content = #{content}, " +
            "    options = #{options}, " +
            "    answer = #{answer}, " +
            "    type = #{type} " +
            "WHERE id = #{id}")
    void update(Question question);


    @Select("select * from question where id = #{questionId}")
    Question getById(Long questionId);



    @Delete("delete from question where id = #{id}")
    void delete(Long id);


    Long countByCondition(@Param("query")QuestionPageQueryDTO query);


    List<QPageResultVO> selectByCondition(@Param("query")QuestionPageQueryDTO query);
}
